package com.device.operating.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.device.operating.dao.DataDictionaryRepository;
import com.device.operating.entity.DataDictionary;
import com.device.operating.service.DataDictionaryService;
import com.device.operating.utils.KeyProvider;

@Service("DataDictionaryService")
@Transactional(propagation=Propagation.REQUIRED)
public class DataDictionaryServiceImpl implements DataDictionaryService{

	@Autowired
	private DataDictionaryRepository datadictionaryRepository;
	
	@Override
	public List<DataDictionary> querybyDataType(String fieldId) {
		// TODO Auto-generated method stub
		return datadictionaryRepository.findByFieldId(fieldId);
	}

	@Override
	public void deletedata(String fieldId) {
		// TODO Auto-generated method stub
		List<DataDictionary> listdata=datadictionaryRepository.findByFieldId(fieldId);
		for(DataDictionary data:listdata);
//		datadictionaryRepository.delete(data);	

	}

	@Override
	public void adddata(String fieldId,String[] fuxuan) {
		// TODO Auto-generated method stub
		DataDictionary data=new DataDictionary();
		deletedata(fieldId);
		for(int i=0;i<fuxuan.length;i++){
			data.setDataId(KeyProvider.getPrimaryKey());
			data.setFieldId(fieldId);
			data.setDatavalue(fuxuan[i]);
//			datadictionaryRepository.save(data);
		}
	}
}
